//
//  ViewController.m
//  20160509作业
//
//  Created by dllo on 16/5/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "SimpleSlider.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createSlider];
    [self creatSeg];
    self.view.backgroundColor = [UIColor whiteColor];
}



- (void)createSlider{
    SimpleSlider *slider = [[SimpleSlider alloc]initWithFrame:CGRectMake(100, 120,self.view.frame.size.width / 2, 40)];
    [self.view addSubview:slider];
    slider.tag = 1;
    slider.minimumValue = 0;
    slider.maximumValue = 255;
    [slider release];
    
    SimpleSlider *slider1 = [[SimpleSlider alloc]initWithFrame:CGRectMake(100, 240, self.view.frame.size.width / 2, 40)];
    [self.view addSubview:slider1];
    slider1.tag = 2;
    slider1.minimumValue = 0;
    slider1.maximumValue = 255;
    [slider1 release];
    SimpleSlider *slider2 = [[SimpleSlider alloc]initWithFrame:CGRectMake(100, 360, self.view.frame.size.width / 2, 40)];
    [self.view addSubview:slider2];
    slider2.tag = 3;
    slider2.minimumValue = 0;
    slider2.maximumValue = 255;
    [slider2 release];
    SimpleSlider *slider3 = [[SimpleSlider alloc]initWithFrame:CGRectMake(100, 480, self.view.frame.size.width / 2, 40)];
    [self.view addSubview:slider3];
    [slider3 release];
   
    
    
    [slider3 addTarget:self action:@selector(handlealpha:) forControlEvents:UIControlEventValueChanged];
    
    [slider addTarget:self action:@selector(handleSlider:) forControlEvents:UIControlEventValueChanged];
    [slider1 addTarget:self action:@selector(handleSlider:) forControlEvents:UIControlEventValueChanged];
    [slider2 addTarget:self action:@selector(handleSlider:) forControlEvents:UIControlEventValueChanged];
    slider.minimumTrackTintColor = [UIColor redColor];
    slider1.minimumTrackTintColor = [UIColor yellowColor];
    slider2.minimumTrackTintColor = [UIColor blueColor];
    
}
- (void)handleSlider:(SimpleSlider *)slider{
    SimpleSlider *a =  [self.view viewWithTag:1];
    SimpleSlider *b = [self.view viewWithTag:2];
    SimpleSlider *c = [self.view viewWithTag:3];
    self.view.backgroundColor = [UIColor colorWithRed:c.value / 255.0f green:a.value / 255.0f blue:b.value / 255.0f alpha:1];
    
}
- (void)handlealpha:(SimpleSlider *)slider{
    self.view.alpha = slider.value;
}


- (void)creatSeg{
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"注册", @"登录", @"用户密码"]];
    seg.frame = CGRectMake(60, 550, 300, 40);
    [self.view addSubview:seg];
    [seg release];
    [seg addTarget:self action:@selector(handleSeg:) forControlEvents:UIControlEventValueChanged];
    
}
- (void)handleSeg:(UISegmentedControl *)seg{
    if (seg.selectedSegmentIndex == 0) {
        
    }


}
@end
